package top.byteio.common.core.constants;

/**
 * 文件类型常量类
 * 包含常见的文件扩展名和MIME类型常量
 * @author lerryxia
 */
public final class FileTypeConstants {

    // 图片文件类型
    public static final String JPG = "jpg";
    public static final String JPEG = "jpeg";
    public static final String PNG = "png";
    public static final String GIF = "gif";
    public static final String BMP = "bmp";
    public static final String WEBP = "webp";
    public static final String SVG = "svg";
    public static final String ICO = "ico";

    // 文档文件类型
    public static final String PDF = "pdf";
    public static final String DOC = "doc";
    public static final String DOCX = "docx";
    public static final String XLS = "xls";
    public static final String XLSX = "xlsx";
    public static final String PPT = "ppt";
    public static final String PPTX = "pptx";
    public static final String TXT = "txt";
    public static final String RTF = "rtf";

    // 压缩文件类型
    public static final String ZIP = "zip";
    public static final String RAR = "rar";
    public static final String _7Z = "7z";
    public static final String TAR = "tar";
    public static final String GZ = "gz";

    // 音频文件类型
    public static final String MP3 = "mp3";
    public static final String WAV = "wav";
    public static final String FLAC = "flac";
    public static final String AAC = "aac";
    public static final String OGG = "ogg";

    // 视频文件类型
    public static final String MP4 = "mp4";
    public static final String AVI = "avi";
    public static final String MKV = "mkv";
    public static final String MOV = "mov";
    public static final String WMV = "wmv";
    public static final String FLV = "flv";
    public static final String WEBM = "webm";

    // 代码文件类型
    public static final String JAVA = "java";
    public static final String JS = "js";
    public static final String TS = "ts";
    public static final String HTML = "html";
    public static final String CSS = "css";
    public static final String XML = "xml";
    public static final String JSON = "json";
    public static final String YAML = "yaml";
    public static final String YML = "yml";
    public static final String SQL = "sql";
    public static final String PROPERTIES = "properties";

    // 可执行文件类型
    public static final String EXE = "exe";
    public static final String MSI = "msi";
    public static final String APP = "app";
    public static final String BAT = "bat";
    public static final String SH = "sh";

    // 对应的MIME类型常量
    public static final String MIME_JPEG = "image/jpeg";
    public static final String MIME_PNG = "image/png";
    public static final String MIME_GIF = "image/gif";
    public static final String MIME_PDF = "application/pdf";
    public static final String MIME_DOC = "application/msword";
    public static final String MIME_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
    public static final String MIME_XLS = "application/vnd.ms-excel";
    public static final String MIME_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    public static final String MIME_MP4 = "video/mp4";
    public static final String MIME_MP3 = "audio/mpeg";
    public static final String MIME_TXT = "text/plain";
    public static final String MIME_HTML = "text/html";
    public static final String MIME_JSON = "application/json";
    public static final String MIME_ZIP = "application/zip";

    // 文件类型分组
    /**
     * 图片文件扩展名数组
     */
    public static final String[] IMAGE_TYPES = {JPG, JPEG, PNG, GIF, BMP, WEBP, SVG, ICO};

    /**
     * 文档文件扩展名数组
     */
    public static final String[] DOCUMENT_TYPES = {PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, RTF};

    /**
     * 压缩文件扩展名数组
     */
    public static final String[] ARCHIVE_TYPES = {ZIP, RAR, _7Z, TAR, GZ};

    /**
     * 音频文件扩展名数组
     */
    public static final String[] AUDIO_TYPES = {MP3, WAV, FLAC, AAC, OGG};

    /**
     * 视频文件扩展名数组
     */
    public static final String[] VIDEO_TYPES = {MP4, AVI, MKV, MOV, WMV, FLV, WEBM};

    /**
     * 检查文件扩展名是否为图片类型
     * @param extension 文件扩展名
     * @return 是否为图片类型
     */
    public static boolean isImageType(String extension) {
        if (extension == null || extension.isEmpty()) {
            return false;
        }
        String ext = extension.toLowerCase();
        for (String type : IMAGE_TYPES) {
            if (type.equals(ext)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查文件扩展名是否为文档类型
     * @param extension 文件扩展名
     * @return 是否为文档类型
     */
    public static boolean isDocumentType(String extension) {
        if (extension == null || extension.isEmpty()) {
            return false;
        }
        String ext = extension.toLowerCase();
        for (String type : DOCUMENT_TYPES) {
            if (type.equals(ext)) {
                return true;
            }
        }
        return false;
    }
}

